package com.xhwl.data.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xhwl.common.dto.cent.sdata.FloorDTO;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Account;
import com.xhwl.common.pojo.cent.sdata.Floor;
import com.xhwl.common.query.cent.sdata.FloorQuery;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: luyi
 * @Description: 楼层
 * @Date: Create in 16:27 2021/1/21
 */
@RestController
public interface IFloorService extends IService<Floor> {

    /**
     * 创建楼层
     * @param floorDTO
     * @return
     */
    @RequestMapping(value = "/floor-service/create", method = RequestMethod.POST)
    ResultJson create(@RequestPart FloorDTO floorDTO);

    /**
     * 更新
     * @param floorDTO
     * @return
     */
    @RequestMapping(value = "/floor-service/update", method = RequestMethod.POST)
    ResultJson update(@RequestPart FloorDTO floorDTO);

    /**
     * 分页
     * @param floorQuery
     * @param account
     * @param page
     * @return
     */
    @RequestMapping(value = "/floor-service/page", method = RequestMethod.POST)
    Page<Floor> page(@RequestPart FloorQuery floorQuery, @RequestPart(required = false) Account account, @RequestPart Page page);

    List<Floor> list(FloorQuery floorQuery);
    /**
     * 删除
     * @param id
     * @param account
     * @return
     */
    @RequestMapping(value = "/floor-service/delete", method = RequestMethod.POST)
    ResultJson delete(@RequestPart Integer id, @RequestPart(required = false) Account account);

    /**
     * 单个查询
     * @param floorQuery
     * @return
     */
    @RequestMapping(value = "/floor-service/find-one", method = RequestMethod.POST)
    Floor find(@RequestPart FloorQuery floorQuery);

    /**
     * 批量创建
     * @param floors
     * @return
     */
    @RequestMapping(value = "/floor-service/batch-insert", method = RequestMethod.POST)
    ResultJson batchCreate(@RequestPart List<FloorDTO> floors);

    ResultJson batchCreateFaster(List<FloorDTO> floors);

    /**
     * 检验编码是否唯一
     *
     * @param floorDTO
     * @return
     */
    Boolean checkUniqueCode(@RequestBody FloorDTO floorDTO);

    /**
     * 获取当前编码
     *
     * @return
     */
    String getCurrentCode();

    /**
     * 通过编码获取楼层信息
     * @param code 编码
     * @return 楼层详情
     */
    @RequestMapping(value = "/floor-service/detail-by-code", method = RequestMethod.POST)
    Floor detailByCode(String code);

    /**
     * 通过编码获取楼层信息
     * @param codes 编码列表
     * @return 楼层详情
     */
    @RequestMapping(value = "/floor-service/detail-by-codes", method = RequestMethod.POST)
    List<Floor> detailByCodes(@RequestPart List<String> codes);

    /**
     * 批量更新
     */
    @RequestMapping(value = "/floor-service/batch-update", method = RequestMethod.POST)
    ResultJson batchUpdate(@RequestPart List<FloorDTO> floors);

    /**
     * 根据 accountId 查询关联楼层
     *
     * @param account
     * @return
     */
    List findByAccount(Account account);

    ResultJson refreshSort(FloorQuery floorQuery);
}
